class Queue:
    """
        环形队列, 理论右进左出
    """
    def __init__(self):
        self.front = 0
        self.rear = 0
        self.maxSize = 12
        self.queue_list = [ None for i in range(self.maxSize)]
    
    def push(self, data):
        # 添加
        if self.is_full():
            return "这个队列已经满了"
        # 这里先添加后移动，是为了满足任何情况下都是空一个
        self.queue_list[ self.rear ] = data
        self.rear = (self.rear + 1) % self.maxSize
        return True
        
    def remove(self):
        # 删除
        if self.is_empty():
            return "这个队列已经空了"
        tmp = self.queue_list[self.front]
        self.queue_list[self.front] = None
        self.front = (self.front + 1) % self.maxSize
        return tmp
    
    def is_full(self):
        """
            队满
            [None, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
            front 指向 None
            rear 指向 10
        """
        if (self.rear + 1) % self.maxSize == self.front:
            return True
        return False
    
    def is_empty(self):
        """
            队空
        """
        if self.rear == self.front:
            return True
        return False
    
    def get_queue_list(self):
        print(self.queue_list)
        

queue = Queue()
for i in range(13):
    z = queue.push(i)
    print(z)
    queue.get_queue_list()

queue.remove()
queue.get_queue_list()

queue.push(11)
queue.get_queue_list()

for i in range(20):
    z = queue.remove()
    print(z)
    queue.get_queue_list()





    